/**
 * @projectName: dataAccessFactory
 * @author: 小飞
 * @description: TODO
 * @date: 2024/2/27 17:21
 * @version: 1.0
 */
package com.example.result;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {

    private int code; //状态码
    private String msg; //返回信息
    private T data; //数据

    public static <T> Result<T> success(){
        Result<T> result = new Result<T>();
        result.code = ResultCde.SUCCESS.getCode();
        return result;
    }
    public static <T> Result<T> success(T object){
        Result<T> result = new Result<T>();
        result.code = ResultCde.SUCCESS.getCode();
        result.data = object;
        return result;
    }
    public static <T> Result<T> error(String msg){
        Result<T> result = new Result<T>();
        result.msg = msg;
        result.code = ResultCde.FAILED.getCode();
        return result;
    }
}
